package view;

import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JLabel;
import java.awt.Point;
import java.awt.Font;
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import javax.swing.ImageIcon;

import common.loadData;

import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class addListCrame extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel Paneltitle = null;
	private JLabel lblistcrame = null;
	private JLabel lbname = null;
	private JTextField txtCrame = null;
	private JButton btnSave = null;
	private JButton btnClose = null;
	private JLabel lbicon = null;

	public addListCrame() {
		super();
		initialize();
	}

	private void initialize() {
		this.setSize(460, 251);
		this.setLocation(new Point(300, 100));
		this.setResizable(false);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/image/List.png")));
		this.setContentPane(getJContentPane());
		this.setTitle("Add Crame");
	}

	private JPanel getJContentPane() {
		if (jContentPane == null) {
			lbicon = new JLabel();
			lbicon.setBounds(new Rectangle(29, 7, 81, 74));
			lbicon.setIcon(new ImageIcon(getClass().getResource("/image/add.png")));
			lbicon.setText("");
			lbname = new JLabel();
			lbname.setBounds(new Rectangle(74, 111, 80, 28));
			lbname.setText("Crame Name:");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getPaneltitle(), null);
			jContentPane.add(lbname, null);
			jContentPane.add(getTxtCrame(), null);
			jContentPane.add(getBtnSave(), null);
			jContentPane.add(getBtnClose(), null);
			jContentPane.add(lbicon, null);
		}
		return jContentPane;
	}

	private JPanel getPaneltitle() {
		if (Paneltitle == null) {
			lblistcrame = new JLabel();
			lblistcrame.setLocation(new Point(0, 0));
			lblistcrame.setFont(new Font("Dialog", Font.BOLD, 18));
			lblistcrame.setForeground(new Color(8, 66, 36));
			lblistcrame.setText("Add Crame");
			lblistcrame.setSize(new Dimension(103, 28));
			Paneltitle = new JPanel();
			Paneltitle.setLayout(null);
			Paneltitle.setBounds(new Rectangle(166, 32, 104, 29));
			Paneltitle.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Color.red));
			Paneltitle.add(lblistcrame, null);
		}
		return Paneltitle;
	}

	private JTextField getTxtCrame() {
		if (txtCrame == null) {
			txtCrame = new JTextField();
			txtCrame.setBounds(new Rectangle(165, 111, 181, 27));
		}
		return txtCrame;
	}

	private JButton getBtnSave() {
		if (btnSave == null) {
			btnSave = new JButton();
			btnSave.setHorizontalTextPosition(SwingConstants.RIGHT);
			btnSave.setIcon(new ImageIcon(getClass().getResource("/image/Save.png")));
			btnSave.setText("Save");
			btnSave.setSize(new Dimension(90, 29));
			btnSave.setLocation(new Point(219, 172));
			btnSave.setHorizontalAlignment(SwingConstants.LEFT);
		}
		return btnSave;
	}

	private JButton getBtnClose() {
		if (btnClose == null) {
			btnClose = new JButton();
			btnClose.setHorizontalTextPosition(SwingConstants.RIGHT);
			btnClose.setIcon(new ImageIcon(getClass().getResource("/image/Close.png")));
			btnClose.setText("Close");
			btnClose.setSize(new Dimension(96, 30));
			btnClose.setLocation(new Point(326, 172));
			btnClose.setHorizontalAlignment(SwingConstants.LEFT);
			btnClose.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					loadData.tab=2;
					mainForm a = new mainForm();
					a.setVisible(true);	
					dispose();
					
				}
			});
		}
		return btnClose;
	}

}
